import type { VNodeChild } from "vue";

export interface DataTableColumnActionDefine {
  name: string;
  key: string;
  icon?: string;
  action: (row: any) => void;
}

export interface DataTableColumnDefine {
  title: string;
  key: string;
  width?: number;
  ellipsis?: boolean;
  action?: DataTableColumnActionDefine[];
  render?: (data: any, index: number) => VNodeChild;
}

export interface DataTableProps {
  idField?: string;
  item: any;
  columns: DataTableColumnDefine[];
  onLoad: (
    page: number,
    pageSize: number,
  ) => Promise<{ data: any[]; total: number }>;
  onGet?: (id: string | number) => Promise<any>;
  onOpenModal?: (item?: any) => void;
  onCloseModal?: (item?: any) => void;
  onSave?: (id?: string | number) => Promise<boolean> | boolean;
  onDelete?: (rows: any[]) => Promise<boolean> | boolean;
}

export interface DataTableMethods {
  refreshData: () => Promise<void>;
  getData: <T>() => T[];
  getSelectedRows: <T>() => T[];
  closeModal: () => void;
  resetPage: () => void;
  getSelectedRow: <T>() => T;
}
